<?php
	//include_once('verifica.php');
	include_once('config/class.pdo.php');
	
	//print_r($_POST[id]);
	if(isset($_POST['id'])) {
		$pdo = new DB;	
		$pdo-> conexao();
		
		$Query = 'SELECT 
					  razaoSocial,
					  nomeFantasia,
					  logo,
					  telefone,
					  idEscritorio
				  FROM escritorio 
		WHERE idEscritorio = '.$_POST['id'].'';
		$result = $pdo->oneReg($Query);				
		//print_r($result);
	} 			
?>
<!doctype html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<link rel="stylesheet" href="css/jquery-ui.css" />
		<link rel="stylesheet" href="css/style.css" />
		<script type="text/javascript" src="js/jquery-1.9.1.js" ></script>
		<script type="text/javascript" src="js/jquery-ui.js" ></script>	
		<script type="text/javascript" src="js/jquery.maskedinput.js" ></script>		
		<script type="text/javascript" src="js/jquery.validate.js" ></script>
		<script type="text/javascript" src="js/jsCadEscritorio.js"></script>	
		<script type="text/javascript" src="js/funcoes.js"></script>			
	</head>	
	<body style="font-size:10px;">
		<form name="frmEscritorio" id="frmEscritorio" method="POST">
			<div id="divEscritorio" class="divEscritorio">
				<fieldset class="backFieldset">
					<legend> <b> Cadastro de Escrit&oacute;rio </b> </legend>
					<table class="table">
						<?php 
							if(isset($_POST['id'])) {
								echo '<tr>';
								echo '<td> Código: </td>';
								echo '<td colspan=3> <input type="text" name="ce_id" id="ce_id" value="'.$result['idEscritorio'].'" readonly /> </td>';
								echo '</tr>';
							}
						?>
						<tr>
							<td> Raz&atilde;o Social : </td>
							<td colspan=3> <input type="text" name="ce_razaoSocial" id="ce_razaoSocial" class="input-xxlarge" title="Campo RAZAO SOCIAL deve ser preenchido." value="<?php echo @$result['razaoSocial']; ?>" required size="100" /> <input type="hidden" name="ce_idEscritorio" id="ce_idEscritorio" title="Campo COD. ESCRIT&Oacute;RIO deve ser preenchido." value="<?php echo @$result['idEscritorio']; ?>" size="11" /></td>
						</tr>
						<tr>
							<td> Nome Fantasia: </td>
							<td colspan=3> <input type="text" name="ce_nomeFantasia" id="ce_nomeFantasia" class="input-xxlarge" title="Campo NOME FANTASIA deve ser preenchido." value="<?php echo @$result['nomeFantasia']; ?>" required size="100" /> </td>
						</tr>	
						<tr>
							<td> Telefone: </td>
							<td colspan=3> <input type="text" name="ce_telefone" id="ce_telefone" title="Campo TELEFONE deve ser preenchido." value="<?php echo @$result['telefone']; ?>" required size="13" /> </td>
						</tr>	
					</table>
				</fieldset>
			</div>
			<?php
				echo '<table>';
					echo '<tr>';
						if(isset($_POST['id'])) {
							echo '<td> <button type="submit" name="atualizar" class="btn btn-success"> <i class="icon-refresh"></i> Atualizar </button>'; 
							echo '    <button type="button" name="cancelar" onclick="apagaForm()" class="btn btn-danger" > <i class="icon-ban-circle"></i> Cancelar </button>';
							echo '    <button type="button" name="voltar" id="voltar" onclick="loadPage(3);" class="btn btn-primary" > <i class="icon-arrow-left"></i> Voltar </button> <input type="hidden" id="controle" value="atualizar"> </td>';
						} else {
							echo '<td> <button type="submit" name="gravar" class="btn btn-success"> <i class="icon-ok"></i> Gravar </button>'; 
							echo '    <button type="button" name="cancelar" onclick="apagaForm()" class="btn btn-danger" > <i class="icon-ban-circle"></i> Cancelar </button>';
							echo '    <button type="button" name="sair" id="sair" onclick="loadPage(1);" class="btn btn-primary" > <i class="icon-home"></i> Sair </button> <input type="hidden" id="controle" value="gravar"> </td>';
						}
					echo '</tr>';
				echo '</table>';
			?>
		</form>
		<div id="retornoEscritorio"> </div>
		<div class="container">
				<h4>Favor preencha os campos abaixo citados:</h4>
				<ol>					
				</ol>
		</div>
	</body>
</html>